//
//  LandmarkDetail.swift
//  WorldLandmarkDemo
//
//  Created by liy on 2025/2/5.
//

import SwiftUI

struct LandmarkDetail: View {
  let landmark: Landmark
  @State private var zoomed = false

  var body: some View {
    ZStack(alignment: .bottomTrailing) {
      Image(landmark.imageName)
        .resizable()
        .aspectRatio(contentMode: zoomed ? .fill : .fit)
        .frame(maxWidth: .infinity, maxHeight: .infinity)
        .onTapGesture {
          withAnimation(.easeInOut(duration: 0.35)) {
            zoomed.toggle()
          }
        }
        .navigationTitle(Text(landmark.imageName))
				.navigationBarTitleDisplayMode(.inline)
      if !zoomed {
        Text(landmark.location)
          .font(.largeTitle)
          .foregroundStyle(.secondary)
          .padding()
          .transition(.move(edge: .trailing))
      }
    }
    
  }
}

#Preview {
  NavigationView {
    LandmarkDetail(landmark: landmarks[1])
  }
}
